// 接口导出文件
import { request } from 'umi';

const baseUrl = 'http://admin-api.macrozheng.com'


export interface ParamsProps {
  username?: string,
  password?: string,
  token?: string
}

// 用户登陆接口
export const getUserLogin = ({ username, password }: ParamsProps) => {
  console.log('---------->:', username, password)
  return request<any>(`${baseUrl}/admin/login`, {
    method: 'POST',
    data: {username, password}
  })
}

// 用户信息接口
export const getUserInfo = ({ token }:ParamsProps) => {
  return request<any>(`${baseUrl}/admin/info`, {
    method: 'GET',
    headers: {
            'Content-Type': 'application/json',
            'Authorization': `${token}`
          }
  })
}

// export const GetUserLogin = () => {
//   return request<any>(`/api/login`);
// }

// export const GetUserInfo = (params: any) => {
//   if (params?.token) {
//     return request<any>(`/api/userInfo`);
//   } else {
//     return Promise.reject({
//       msg: 'fail'
//     })
//   }
// }

// export const GetUserInfo = () => {
//   return request<any>(`${baseUrl}/admin/info`, {
//     method: 'GET',
//     headers: {
//       'Content-Type': 'application/json',
//       'Authorization': 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImNyZWF0ZWQiOjE2MjYyMzM0ODA2MjEsImV4cCI6MTYyNjgzODI4MH0.59vOnP8ZhbYb3djzidbLGyEtKImTnUcJ-cAfX62FkvlcoUA9fiEkNE0oEbLQDbVg7PmMmcdNUb6D1EX-R0hSeA'
//     },
//   });
// }

// export const GetTestApi = () => {
//   return request<any>('/api/list', {
//     method: 'GET',
//   });
// }
